"""
单元测试
"""
import unittest
from .ImageShop import ImageShop as Is


class UnitTestImageShop(unittest.TestCase):

    def setUp(self) -> None:
        self.file_path = "Resource/1.jpeg"
        self.dir_path = "Resource"

    def test_load_images_file(self):
        is1 = Is(self.file_path)
        is1.load_images()
        self.assertEqual(len(is1._images), 1)

    def test_load_images_dir(self):
        is1 = Is(self.dir_path, "jpg")
        is1.load_images()
        self.assertEqual(len(is1._images), 5)

    def test_batch_ps(self):
        is1 = Is(self.file_path)
        is1.load_images()
        is1.batch_ps(("Sharpen",),("Resize",(250,250)))
        is1._results[0].show()
    
    def test_display(self):
        is1 = Is(self.dir_path, "jpg")
        is1.load_images()
        is1.display(2,2,(100, 100), 3)
    
    def test_save_file(self):
        fp = "output/1.png"
        is1 = Is(self.file_path)
        is1.load_images()
        is1.batch_ps(("Resize",(250,250)))
        is1.save(fp, "png")

    def test_save_dir(self):
        dp = "output/"
        is1 = Is(self.dir_path)
        is1.load_images()
        is1.batch_ps(("Resize",(250,250)))
        is1.save(dp, "png")


if __name__ == '__main__':
    unittest.main()
